1. Technology Field
The present invention generally relates to a wear leveling method, in particular, to a wear leveling method for a flash memory and a controller using the same.
2. Description of Related Art
Along with the widespread of digital cameras, camera phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically too. Flash memory is one of the most adaptable memories for such battery-powered portable products due to its characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure. Besides being applied in foregoing portable products, flash memory is also broadly applied to external products such as flash cards and flash drives. Thereby, flash memory has become one of the most focused electronic products in recent years.
Even though a flash memory can offer such advantages as data rewritability and power-free data storage, blocks in a flash memory can only be erased a limited number of times. For example, a block in a flash memory will be worn-out after being erased 10,000 times. Data loss may be caused when the storage capacity or performance of a flash memory is obviously deteriorated by its worn-out blocks.
The wear of a block in a flash memory is determined by the number of times this block is programmed or erased. In other words, the wear of a block is relatively low if the block is programmed (or written) only once; contrarily, the wear of a block grows higher when the block is programmed and erased repeatedly. For example, when a host keeps writing data into a flash memory by using the same logical block address (LBA), the block corresponding to the same physical block address (PBA) in the flash memory is then repeatedly written and erased.
Generally speaking, the existence of worn-out blocks will affect the performance of a flash memory even if the wear of other blocks is still relatively low. Besides the deterioration in the performance of the worn-out blocks, the performance of the entire flash memory is also reduced when the good blocks cannot provide enough space for storing data. In other words, when the number of worn-out blocks in a flash memory exceeds a threshold, the flash memory is considered unusable even there are still good blocks. In this case, those good blocks are wasted.
As described above, blocks in a flash memory should be used evenly in order to prolong the lifespan of the flash memory. Conventionally, a block swapping operation is performed after the flash memory has been accessed for a certain period so as to level the wear of the blocks. According to the conventional block swapping technique, the same block swapping rule is applied to all the blocks in a flash memory. However, blocks in a flash memory are usually grouped into different areas, and these areas are accessed in different manners therefore are worn out differently. Thus, meaningless system resource consumption may be caused by swapping all the blocks in a flash memory based on the same block swapping rule. Accordingly, a wear leveling method which can effectively prolong the lifespan of a flash memory and at the same time, can prevent meaningless consumption of system resources by considering the characteristics of different areas in the flash memory is desired.